<% options = local_assigns.fetch(:options, {}) %>

<%= content_tag :div,
  class: picture_editor.css_classes,
  data: picture_editor.data_attributes do %>
  <%= element_form.fields_for(:ingredients, picture_editor.ingredient) do |f| %>
    <%= ingredient_label(picture_editor, :picture_id, for: nil) %>
    <%= content_tag :div,
      data: {
        target_size: picture_editor.settings[:size] || [
          picture_editor.image_file_width.to_i,
          picture_editor.image_file_height.to_i
        ].join("x"),
        image_cropper: picture_editor.thumbnail_url_options[:crop],
      },
      class: "picture_thumbnail" do %>
      <a class="picture_tool delete">
        <%= render_icon("close") %>
      </a>
      <div class="picture_image">
        <%= render Alchemy::Admin::PictureThumbnail.new(
          picture_editor,
          css_class: "img_paddingtop",
          placeholder: render_icon(:image, size: "xl")
        ) %>
      </div>
      <%- if picture_editor.css_class.present? -%>
        <%= render "alchemy/ingredients/shared/picture_css_class", {
          css_class: picture_editor.css_class
        } %>
      <%- end -%>
      <div class="edit_images_bottom">
        <%= render "alchemy/ingredients/shared/picture_tools", {
          picture_editor: picture_editor
        } %>
      </div>
    <% end %>
    <%= f.hidden_field :picture_id, value: picture_editor.picture&.id,
      id: picture_editor.form_field_id(:picture_id),
      data: {
        picture_id: true,
        image_file_width: picture_editor.image_file_width,
        image_file_height: picture_editor.image_file_height
      } %>
    <%= f.hidden_field :link, data: { link_value: true }, id: nil %>
    <%= f.hidden_field :link_title, data: { link_title: true }, id: nil %>
    <%= f.hidden_field :link_class_name, data: { link_class: true }, id: nil %>
    <%= f.hidden_field :link_target, data: { link_target: true }, id: nil %>
    <%= f.hidden_field :crop_from, data: { crop_from: true }, id: picture_editor.form_field_id(:crop_from) %>
    <%= f.hidden_field :crop_size, data: { crop_size: true }, id: picture_editor.form_field_id(:crop_size) %>
  <% end %>
<% end %>
